<template>
    <div>
        <el-card>
            <el-form :inline="true">
                <el-form-item label="一级分类">
                    <el-select :disabled="scene==0?false:true" @change="getC2" v-model="categoryStore.c1Id">
                        <el-option v-for="(c1) in categoryStore.c1Arr" :key="c1.id" :label="c1.name" :value="c1.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="二级分类">
                    <el-select :disabled="scene==0?false:true" @change="getC3" v-model="categoryStore.c2Id">
                        <el-option v-for="c2 in categoryStore.c2Arr" :label="c2.name" :key="c2.id" :value="c2.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="三级分类">
                    <el-select :disabled="scene==0?false:true" v-model="categoryStore.c3Id">
                        <el-option v-for="c3 in categoryStore.c3Arr" :label="c3.name" :key="c3.id" :value="c3.id">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-form>
        </el-card>
    </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue';

import useCategoryStore from '@/store/modules/category'

let categoryStore = useCategoryStore()
onMounted(() => {
    getC1()
})
const getC1 = () => {
    categoryStore.getC1()
}
const getC2 = () => {
    categoryStore.c2Id = ''
    categoryStore.c3Id = ''
    categoryStore.c3Arr = []
    categoryStore.getC2()
}
const getC3 = () =>{
    categoryStore.c3Id = ''
    categoryStore.getC3()
}
defineProps(['scene'])
</script>

<style scoped></style>